<?php

namespace app\Http\Middleware;

use Closure;
use App\User;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Support\Facades\Auth;
use App\Models\SystemSetting;

class Initialize
{
    /**
     * The Guard implementation.
     *
     * @var Guard
     */


    /**
     * Create a new filter instance.
     *
     * @param  Guard  $auth
     * @return void
     */


    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $setting = SystemSetting::all();
        //初始化项目数量5
        if(count($setting)<9){
            return redirect('/admin/initialize');
        }
         foreach ($setting as $s){
             if($s->is_set==0)
                 return redirect('/admin/initialize');
         }

        return $next($request);
    }

}
